/**
*
* @author Anastasiya
*
*/

#include "arguments.h"
#include "util.h"
#include <string>
#include <cstdlib>

using namespace std;
using namespace utl;

namespace args{
	Arguments* parseArgs(const int argc, char* argv[]){
		Arguments* arguments = defaultArguments();

		for(int i = 1; i < argc; i++){
			string currentArg = string(argv[i]);
			if(isInput(currentArg)){
				i++;
				if(i < argc){
					arguments->inputPath = string(argv[i]);
				}else{
					throw MESSAGE_ARGUMENT_ERROR_INPUT_VALUE;
				}
			}else if(isTest(currentArg)){
				arguments -> testMode = true;
			}else{
				throw MESSAGE_ARGUMENT_ERROR_UNKNOWN_ARGUMENT;
			}
		}

		return arguments;
	}

	Arguments* defaultArguments(){
		Arguments* arguments = new Arguments();

		arguments->testMode = false;
		arguments->inputPath = DEFAULT_PATH;

		return arguments;
	}

	bool isTest(const string arg){
		return arg.compare(ARGUMENT_NAME_TEST) == 0;
	}
	bool isInput(const string arg){
		return arg.compare(ARGUMENT_NAME_INPUT) == 0;
	}
}